package cjq.demo.tess4j;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;

/**
 * author: cjianquan
 * date: 2016/12/23
 */
public class TesseractExample {
    public static void main(String[] args) {
        File imageFile = new File("E:\\ideaWorkspace\\test\\2.jpg");
        ITesseract instance = new Tesseract();  // JNA Interface Mapping
        instance.setDatapath("D:\\Tesseract-OCR");
//        instance.setLanguage("osd.traineddata");
//        ITesseract instance = new Tesseract1(); // JNA Direct Mapping

        try {
            String result = instance.doOCR(imageFile);
            System.out.println(result);
        } catch (TesseractException e) {
            System.err.println(e.getMessage());
        }
    }
}
